import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '采购单编号',
    align:"center",
    dataIndex: 'orderSn'
   },
   {
    title: '订购人',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '总金额',
    align:"center",
    dataIndex: 'money'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '采购单编号',
    field: 'orderSn',
    component: 'Input',
  },
  {
    label: '订购人',
    field: 'name',
    component: 'Input',
  },
  {
    label: '总金额',
    field: 'money',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//子表列表数据
export const erpAaOrderProductColumns: BasicColumn[] = [
   {
    title: '水果',
    align:"center",
    dataIndex: 'shuiguo'
   },
   {
    title: '单价',
    align:"center",
    dataIndex: 'price'
   },
   {
    title: '数量',
    align:"center",
    dataIndex: 'num'
   },
   {
    title: '合计',
    align:"center",
    dataIndex: 'total'
   },
];
//子表表单数据
export const erpAaOrderProductFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '水果',
    field: 'shuiguo',
    component: 'Input',
  },
  {
    label: '单价',
    field: 'price',
    component: 'InputNumber',
  },
  {
    label: '数量',
    field: 'num',
    component: 'InputNumber',
  },
  {
    label: '合计',
    field: 'total',
    component: 'InputNumber',
  },
];
//子表列表数据
export const erpAaOrderAddressColumns: BasicColumn[] = [
   {
    title: '地址',
    align:"center",
    dataIndex: 'address'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '手机号码',
    align:"center",
    dataIndex: 'mobile'
   },
   {
    title: '邮箱',
    align:"center",
    dataIndex: 'email'
   },
];
//子表表单数据
export const erpAaOrderAddressFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '地址',
    field: 'address',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '手机号码',
    field: 'mobile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'},
          ];
     },
  },
];

// 高级查询数据
export const superQuerySchema = {
  orderSn: {title: '采购单编号',order: 0,view: 'text', type: 'string',},
  name: {title: '订购人',order: 1,view: 'text', type: 'string',},
  money: {title: '总金额',order: 2,view: 'text', type: 'string',},
};
